//
//  SZViewController.m
//  SZTabBarContentView
//
//  Created by isstarz@163.com on 09/14/2017.
//  Copyright (c) 2017 isstarz@163.com. All rights reserved.
//

#import "SZViewController.h"
#import <SZTabBarContentView/SZTabBarContentView.h>
#import <Masonry/Masonry.h>


#define RandomColor [UIColor colorWithRed:arc4random_uniform(256)/ 255.0f green:arc4random_uniform(256)/ 255.0f blue:arc4random_uniform(256)/ 255.0f alpha:1.0f]

@interface SZViewController ()<SZTabBarContentViewDelegate, SZTabBarContentViewDataSource>

@property (nonatomic, strong) SZTabBarContentView *tabBarContentView;

@end

@implementation SZViewController{
    NSInteger _count;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    _count = arc4random_uniform(6) + 2;
	
    self.tabBarContentView = [SZTabBarContentView new];
    
    self.tabBarContentView.delegate = self;
    self.tabBarContentView.dataSource = self;
    
    [self.view addSubview:self.tabBarContentView];
    
    [self.tabBarContentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.view);
        make.size.mas_equalTo(CGSizeMake(300, 500));
    }];
    
    [self.tabBarContentView reloadData];
    
    
}


#pragma mark - SZTabBarContentViewDataSource

- (NSInteger)numberOfItemsInTabBarContentView:(SZTabBarContentView *)tabBarContentView
{
    return _count;
}

- (NSString *)tabBarContentView:(SZTabBarContentView *)tabBarContentView titleAtItemsIndex:(NSInteger)index
{
    return @"标题";
}


- (UIView *)tabBarContentView:(SZTabBarContentView *)tabBarContentView contentViewAtItemsIndex:(NSInteger)index
{
    UIView *view = [UIView new];
    view.backgroundColor = RandomColor;
    return view;
}

#pragma mark - SZTabBarContentViewDelegate
- (CGFloat)tabBarHeightInTabBarContentView:(SZTabBarContentView *)tabBarContentView
{
    return 44;
}

@end
